#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2018, Niklas Hauser
#
# This file is part of the modm project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# -----------------------------------------------------------------------------


def init(module):
    module.name = ":driver:mcp23x17"
    module.description = """\
# MCP23x17 16-Bit I/O Expander

Port GPB is the high byte, GPA the low byte.
The lower three address bits can be configured: `0100abc`.

Notice that you can specify multiple pins at the same time for functions
with argument type `Pins`, either by ORing the according pins, or
converting a 16bit value using the `Pins(uint16_t)` converting constructor.

Other functions with argument type `Pin` can only take one pin.
If you want to operate on all 16bit, use the `get(Inputs|Outputs|Directions|Polarities)()`
getters.
"""

def prepare(module, options):
    module.depends(
        ":architecture:gpio.expander",
        ":architecture:i2c.device",
        ":architecture:register",
        ":architecture:spi.device",
        ":processing:resumable")
    return True

def build(env):
    env.outbasepath = "modm/src/modm/driver/gpio"
    env.copy("mcp23x17.hpp")
    env.copy("mcp23x17_impl.hpp")
    env.copy("mcp23_transport.hpp")
    env.copy("mcp23_transport_impl.hpp")
